package com.hmdp.utils;

import com.hmdp.constant.GlobalConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class RedisIdWork {
    @Autowired
    RedisTemplate redisTemplate;
    public Long getId()
    {
        Long increment = redisTemplate.opsForValue().increment(GlobalConstant.AUTO_INCREMENT_Voucher_ID);
        long curr = System.currentTimeMillis();
        return (curr<<32)+increment;
    }
}
